package com.jason.learn.springcloud.accountservice.service;

import com.jason.learn.springcloud.accountservice.dao.AccountDao;
import com.jason.learn.springcloud.accountservice.mapper.AccountMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Calendar;

@Service
public class AccountService {
    @Autowired
    private AccountDao accountDao;

    @Autowired
    private AccountMapper accountMapper;

    public boolean addMoney(Long accountId, BigDecimal amount){
        // 一些其他业务逻辑
        accountDao.addMoney(accountId,amount);
        // 一些其他业务逻辑
        return true;
    }

    public boolean createAccount(Long accountId,BigDecimal amount) {
        try {
            accountMapper.addAccount(accountId,amount, Calendar.getInstance().getTime());
            return true;
        }catch (Exception ex){
            return false;
        }
    }
}
